/**
  * @author juntao zhang
  */
object DefAndVal extends App{
    /**
      * //变量
       String b = "hello";
       private final String a$1()
      {
        return "hello";
      }
      */
    def a = "hello"
    val b = "hello"
    /**
      * private final Function1 even1$1()
        {
          return new AbstractFunction1.mcZI.sp() { public static final long serialVersionUID = 0L;
            public final boolean apply(int x$1) { return apply$mcZI$sp(x$1); }
            public boolean apply$mcZI$sp(int x$1) { return x$1 % 2 == 0; } } ;
        }
      */
    def even1: (Int => Boolean) = (_ % 2 == 0) //返回值是一个函数 这种做法不好
    /**
      * Function1 even2 = new AbstractFunction1.mcZI.sp() { public static final long serialVersionUID = 0L;
          public final boolean apply(int x$2) { return apply$mcZI$sp(x$2); }
          public boolean apply$mcZI$sp(int x$2) { return x$2 % 2 == 0;
          }
        };
      */
    val even2: (Int => Boolean) = (_ % 2 == 0)
    /**
      * private final boolean even3$1(int x) { return x % 2 == 0; }
      */
    def even3(x: Int): Boolean = {
      x % 2 == 0
    }
    lazy val even4: Int => Boolean = _ % 2 == 0 //只是比even2晚创建
    even1(13)
    even2(13)
    even3(13)
    even4(13)
    /**
      * private final void fun1_2$1()
        {
          Predef..MODULE$.println("fun1_2");
        }
        private final int fun1$1(int x) { fun1_2$1();
          Predef..MODULE$.println("fun1");
          return 2 * x;
        }
      */
    def fun1(x: Int): Int = {
      def fun1_2() = {
        println("fun1_2")
      }
      fun1_2()
      println("fun1")
      2 * x
    }
    val fun2 = (x: Int) => {
      println("fun2")
      2 * x
    }
    fun1(3)
    fun2(3)
}
